package com.interview.item.javabase.mvcFilter;

import org.apache.catalina.filters.SetCharacterEncodingFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

/**
 * @Author:zxh
 * @Description:
 * @Date: 2020/8/25
 * @Modified By:
 */
@Configuration
@EnableWebMvc
@Import({WebConfig.class})
public class WebConfig implements WebMvcConfig {
 /*   @Autowired
    private */

 @Bean
    public FilterRegistrationBean setCharacterEncodingFilter(){
     FilterRegistrationBean registrationBean = new FilterRegistrationBean(new SetCharacterEncodingFilter());
     registrationBean.addUrlPatterns("/*");
     registrationBean.addInitParameter("encoding","utf-8");
     registrationBean.setName("setCharactEncodingFilter");
     registrationBean.setOrder(0);
     return registrationBean;
 }

    @Bean
    public FilterRegistrationBean setCharacterEncodingFilterTwo(){
        FilterRegistrationBean registrationBean = new FilterRegistrationBean(new SetCharacterEncodingFilter());
        registrationBean.addUrlPatterns("/*");
        registrationBean.addInitParameter("encoding","utf-8");
        registrationBean.setName("setCharactEncodingFilter");
        registrationBean.setOrder(1);
        return registrationBean;
    }
}
